import { queryDrawYear } from "@/api/drawHist";

const useFetchYr = defineStore("drawHist-fetchYr", () => {
  const route = useRoute();
  const yearList = ref<(string | number)[]>([]);

  const curYear = ref(route.query.year as string);
  async function fetchDrawYr() {
    if (yearList.value.length) {
      return;
    }
    const res = await queryDrawYear();
    yearList.value = res?.data ?? [];
  }

  return { yearList, fetchDrawYr, curYear };
});
export const useFetchYrRefs = () => storeToRefs(useFetchYr());
export default useFetchYr;
